package com.doit.day02;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class _01_比较器 {
    public static void main(String[] args) {
        ArrayList<OrderInfo> list = new ArrayList<>();
        list.add(new OrderInfo("o001","u001","c001",99.99,2));
        list.add(new OrderInfo("o003","u003","c003",89.99,4));
        list.add(new OrderInfo("o005","u005","c005",59.99,5));
        list.add(new OrderInfo("o006","u006","c006",49.99,7));
        list.add(new OrderInfo("o004","u004","c004",79.99,6));
        list.add(new OrderInfo("o002","u002","c002",69.99,3));
        list.add(new OrderInfo("o008","u008","c008",39.99,9));
        list.add(new OrderInfo("o007","u007","c007",9.99,1));

        //请你给集合中的订单排个序，那你得说清楚，咱们到底按照什么进行比较
        //比较规则
        Collections.sort(list, new Comparator<OrderInfo>() {
            @Override
            public int compare(OrderInfo o1, OrderInfo o2) {
                return -o1.getOid().compareTo(o2.getOid());
            }
        });

        for (OrderInfo orderInfo : list) {
            System.out.println(orderInfo);
        }

        ArrayList<String> integers = new ArrayList<>();
        integers.add("1");
        integers.add("3");
        integers.add("5");
        integers.add("7");
        integers.add("9");
        integers.add("8");

        Collections.sort(integers);
        System.out.println(integers);

    }
}
